package com.ydy.quartz.task;

import com.ydy.quartz.util.SpringUtils;
import com.ydy.quartz.service.MailService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDate;

public class SendEmailJob implements Job {

    private static Logger LOGGER = LoggerFactory.getLogger(SendEmailJob.class);

    private MailService mailService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        mailService = SpringUtils.getBean(MailService.class);
        LOGGER.info("处理任务开始{}，参数为{}", LocalDate.now(),context);
        String subject = "晚安祝福";
        String content = "老婆晚安";
        String filePath = "/ydy-destined/title.png";
        String to = "191176549@qq.com";
        mailService.sendAttachmentsMail(subject,content,filePath,to);
    }
}
